package com.ruoyi.result.copyright.mapper;

import java.util.List;
import java.util.Map;

import com.ruoyi.result.copyright.domain.ResultCopyright;
import com.ruoyi.result.copyright.domain.dto.ResultCopyrightDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 软件著作权Mapper接口
 *
 * @author ruoyi
 * @date 2025-01-14
 */
@Mapper
public interface ResultCopyrightMapper
{
    /**
     * 查询软件著作权
     *
     * @param id 软件著作权主键
     * @return 软件著作权
     */
    public ResultCopyright selectResultCopyrightById(Long id);

    /**
     * 查询软件著作权列表
     *
     * @param resultCopyright 软件著作权
     * @return 软件著作权集合
     */
    public List<ResultCopyright> selectResultCopyrightList(ResultCopyrightDTO resultCopyright);

    /**
     * 新增软件著作权
     *
     * @param resultCopyright 软件著作权
     * @return 结果
     */
    public int insertResultCopyright(ResultCopyright resultCopyright);

    /**
     * 修改软件著作权
     *
     * @param resultCopyright 软件著作权
     * @return 结果
     */
    public int updateResultCopyright(ResultCopyright resultCopyright);

    /**
     * 删除软件著作权
     *
     * @param id 软件著作权主键
     * @return 结果
     */
    public int deleteResultCopyrightById(Long id);

    /**
     * 批量删除软件著作权
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteResultCopyrightByIds(Long[] ids);

    List<ResultCopyright> selectResultCopyrightByIds(Long[] ids);

    @Select("SELECT COUNT(*) FROM result_copyright WHERE sync_status = '是' AND is_deleted = 0")
    long selectCount();

    @Select("SELECT YEAR(puttime) as year, COUNT(*) as count FROM result_copyright " +
            "WHERE is_deleted = 0 " +
            "GROUP BY YEAR(puttime) " +
            "ORDER BY year")
    List<Map<String, Object>> countByYear();

    @Select("SELECT YEAR(puttime) as year, COUNT(*) as count FROM result_copyright " +
            "WHERE is_deleted = 0 AND user_id = #{userId} " +
            "GROUP BY YEAR(puttime) " +
            "ORDER BY year")
    List<Map<String, Object>> countByYearAndUserId(@Param("userId") Long userId);

    List<ResultCopyright> selectResultCopyrightListByDept(ResultCopyrightDTO resultCopyright);
}
